package com;

import java.time.LocalDateTime;
import java.util.List;

public class Manager extends User {
    public Manager(String userId, String username, String password,
                   LocalDateTime registerTime, String phone) {
        super(userId, username, password, registerTime, "经理", phone);
                                                             }
    @Override
    public boolean login(String inputUsername, String inputPassword) {
        return this.getUsername().equals(inputUsername) && this.getPassword().equals(inputPassword);
                                                                     }
    public void addMovie(Movie movie, List<Movie> movieList, LogService logService) {
        movieList.add(movie);
        logService.recordLog("添加影片", this, "添加影片《" + movie.getTitle() + "》");
                                                                                    }
    public void updateMovie(Movie movie, List<Movie> movieList, LogService logService) {
        for (int i = 0; i < movieList.size(); i++) {
            if (movieList.get(i).getMovieId().equals(movie.getMovieId())) {
                movieList.set(i, movie);
                logService.recordLog("更新影片", this, "更新影片《" + movie.getTitle() + "》");
                return;                                                   }
                                                   }
        System.out.println("错误：未找到该影片");                                        }
    public void addSchedule(Schedule schedule, List<Schedule> scheduleList, LogService logService) {
        scheduleList.add(schedule);
        logService.recordLog("添加场次", this,
                "为影片《" + schedule.getMovie().getTitle() + "》添加" +
                        schedule.getShowTime() + "场次");                                          }
    public double calculateDailyRevenue(List<Ticket> ticketList, LocalDateTime date) {
        double total = 0;
        for (Ticket ticket : ticketList) {
            if (ticket.getSchedule().getShowTime().toLocalDate().equals(date.toLocalDate())
                    && !ticket.isRefunded()) {
                total += ticket.getPrice();  }
                                         }
        return total;                                                                }
                              }
